/*
 * @Description:
 * @Author: 稽辉
 * @Date: 2025-02-25 16:38:50
 * @LastEditTime: 2025-03-16 09:31:27
 * @LastEditors: 稽辉
 */
import type { GoodsItem } from '@/types/global'
import type { GoodsResult } from '@/types/goods'
import { http } from '@/utils/http'

//封装api
/**
 * 商品详情
 * @param id 商品id
 * @returns
 */
export const getGoodsResultById = (id: string) => {
  return http<GoodsResult>({
    method: 'GET',
    url: '/goods',
    data: {
      id,
    },
  })
}
export const getGoodByIdAPI = (id: string) => {
  return http<GoodsItem>({
    method: 'GET',
    url: '/goods/get-by-id',
    data: {
      id,
    },
  })
}

export const submitGoodScoreAPI = (score: number, goodId: string, userId: number) => {
  return http<GoodsItem>({
    method: 'POST',
    url: '/goods/score',
    data: {
      score,
      goodId,
      userId,
    },
  })
}

export const getScoreRecordByIdAPI = (goodId: string, userId: number) => {
  return http<number>({
    method: 'GET',
    url: '/goods/get-score-record',
    data: {
      goodId,
      userId,
    },
  })
}
export const getScoreNumByGoodIdAPI = (goodId: string) => {
  return http<number>({
    method: 'GET',
    url: '/goods/get-good-score-num',
    data: {
      goodId,
    },
  })
}
